<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <title>选择发票</title>
    <link rel="stylesheet" href="css/supplement.css"/>
    <!-- 公用样式css -->
    <link href="css/base.css" rel="stylesheet" type="text/css" />
    <!-- 界面引入css -->
    <link href="css/interests-member.css" rel="stylesheet" type="text/css" />
    <!-- ui框架引入css -->
    <link href="css/weui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery-weui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/bootstrap-switch.css" rel="stylesheet" type="text/css" />
    
    <style media="screen">
        * {margin: 0;padding: 0;}
        ul {list-style: none;}
        .sl-content {
            overflow: hidden;
        }
        .sl-content img {
            width: 120px;
            height: auto;
            margin-right: 8px;
            float: left;
        }
        .frame_div{position: fixed;width: 100%; height:100%;z-index: 10000;display:none;left:0;top:0}
		.tsxx{ padding:10px; border-top:1px solid #eee; color:#666;}
		.fplb-all{ height:auto; overflow:hidden; position:relative; border:1px solid #eee; padding:10px;}
		.fplb-all>li:nth-of-type(1){ width:30px; position:absolute; top:25px;}
		.fplb-all>li:nth-of-type(2){ margin-left:35px; margin-right:30px;}
		.fplb-all>li:nth-of-type(3){ position:absolute; width:30px; top:20px; right:10px;}
    </style>
</head>
<body  style="background:#fff;">
	<header class="header">
        <div class="header-left wor-colour6" onclick="_back()">取消</div>
        <div class="header-center word5 "><a class="header-arrow">发票列表</a></div>
        <div class="header-right wor-colour6" onclick="selectInvoice()">确定</div>
    </header>
	<div class="main bot60">
		<ul class="defrayal">
			<li class="word4"><span>不需要发票</span>
				<span class="float-r">
					 <input name="status" type="checkbox" <c:if test="${needInvoice}">checked </c:if> data-size="small" id="needInvoice">
                     <input type="hidden" name="needInvoiceType" id="needInvoiceType" value="${needInvoice}">
			    </span>
			</li>
		</ul>
        <div class="tsxx">提示：按照国税总局公告，自2017年7月1日起，企业索取的增值税普通发票需要填写纳税人识别号，不符合规定的发票，不得作为合法税收凭证</div>
        <div id="fpdiv" style="width:100%;display:none">
        <div class="common-tj"><button class="button-rzr wor-colour6" onclick="_addInfo('${sessionScope.memKey}');return false;">添加发票</button></div>
			<c:if test="${not empty dataList}">
				<c:forEach var="info" items="${dataList}">
				<ul class="fplb-all">
					<li>
						<div class="fit_box">
					        <input type="radio" value="${info.Code}" id="checkbox${info.Code}" selTitle="${info.Title}" name="check">
					        <label for="checkbox${info.Code}" ></label>
					   	</div>
					</li>
					<li style="padding-left:15px;">
						<p>${info.Title}</p>
						<p>识别号：${info.CreditCode}</p>
						<p>领取方式：
							<c:if test="${info.TakeType == 0}">离店时领取</c:if>
							<c:if test="${info.TakeType == 1}">入住时领取</c:if>
							<c:if test="${info.TakeType == 2}">快递寄出</c:if>
						</p>
					</li>
<%-- 					<c:if test="${info.InvoiceType==0}">
						<li onclick="_modifyInfo('${info.Code}','${info.InvoiceType}','${info.Title}','${info.CreditCode}',
						'${info.RegisterAddress}','${info.CompanyPhone}','','${info.OpeningAccount}',
						'${info.TakeType}','${info.DefaultSign}','${sessionScope.memKey}');return false">
					</c:if>
					<c:if test="${info.InvoiceType==1}">
						<li onclick="_modifyInfo('${info.Code}','${info.InvoiceType}','${info.Title}','${info.CreditCode}',
						'${info.RegisterAddress}','${info.CompanyPhone}','${info.OpeningBank}','${info.OpeningAccount}',
						'${info.TakeType}','${info.DefaultSign}','${sessionScope.memKey}');return false">
					</c:if>
			        	<img src="images/write.png" width="30" height="30" />
			        </li> --%>
				</ul>
				</c:forEach>
			</c:if>
			<c:if test="${empty dataList}"><img style="width:90%;margin-left:5%;" src="<%=basePath%>/images/icon38.png"></c:if>
        </div>
	</div>
</body>
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery/swiper.js"></script>
<script type="text/javascript" src="js/bootstrap-switch.js"></script>
<script type="text/javascript" src="js/idangerous.swiper.min.js"></script>
<script type="text/javascript" src="js/artDialog/artDialog.source.js?skin=simple"></script>
<script type="text/javascript" src="js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript">
	 $(function() {// 初始化内容
        $('[name="status"]').bootstrapSwitch({
            onColor:"success",
            offColor:"default",
            size:"small",
            onSwitchChange:function(event,state){
                if(state==true){
                    $("#fpdiv").show();
                }else{
                    $("#fpdiv").hide();
                }
            }
        });
        if(${needInvoice}){
            $("#fpdiv").show();
            $("#needInvoice").prop("checked",true);
        }else{
            $("#fpdiv").hide();
            $("#needInvoice").prop("checked",false);
        }
    });
	function selectInvoice() {
		var selected = "";
		var title = "不需要发票";
		if ($("#needInvoice").prop("checked")) {
			$("input[name='check']").each(function() {
				if ($(this).get(0).checked) {
					selected = $(this).val();
					title = $(this).attr("selTitle");
				}
			});
		}
		$('#invoiceCode', window.parent.document).val(selected);
		$('#invoiceLi', window.parent.document).html(title);
		$('#invoiceDiv', window.parent.document).hide();
		$("#frame_div_back", window.parent.document).hide();
	}

	function _back() {
		$('#invoiceDiv', window.parent.document).hide();
		$("#frame_div_back", window.parent.document).hide();
	}

	function _addInfo(memKey) {
	    var needInvoice = $("#needInvoice").prop("checked");//单选状态
		var url = "<%=basePath%>/member/gotoAddOrdinaryInvoice?type=2&needInvoice="+needInvoice+"&memKey="+memKey;
        window.location.replace(url);
	}

	function _modifyInfo(code, invoiceType, title, creditCode, registerAddress, companyPhone, openingBank, openingAccount, takeType, defaultSign,memKey) {
		var url = "";
		if (invoiceType == 1) { //0专用
			url = "<%=basePath%>member/gotoEditOrdinaryInvoice?code=" + code + "&invoiceType=" + invoiceType + "&title=" + title + "&creditCode=" + creditCode + "&takeType=" + takeType + "&defaultSign=" + defaultSign + "&type=2&memKey=${sessionScope.memKey}";
		} else if (invoiceType == 0) { //1普通
			url = "<%=basePath%>member/gotoEditValueInvoice?code=" + code + "&invoiceType=" + invoiceType + "&title=" + title + "&creditCode=" + creditCode + "&registerAddress=" + registerAddress + "&companyPhone=" + companyPhone +
				"&openingBank=" + openingBank + "&openingAccount=" + openingAccount + "&takeType=" + takeType + "&defaultSign=" + defaultSign + "&type=2&memKey=${sessionScope.memKey}";
		}
        window.location.replace(url);
	}
</script>
</html>
